#if !defined(_SVECTOR_H)
#define _SVECTOR_H

#include "SComplexValue.h"
#include "SByte.h"
#include "SVectorTypeDescriptor.h"
#include <boost/foreach.hpp>
#include <boost/regex.hpp>

CREATE_ALIAS( SVector );

/**
 * Class used to store a vector value.
 */
class DECLARATION_DLL SVector : public SComplexValue
{
	/** Elements of the vector. */
	SValueSpVectorSp values;

	/** The type descriptor. */
	SVectorTypeDescriptorSp typeDescriptor;
	
	/**
	 * Create a SVector variable.
	 */ 
	SVector(SVectorTypeDescriptorSp typeDescriptor);

	public:

		/**
		 *   Get the variable type.
		 */
		virtual SType GetType() const
		{
			return STypeVector;
		}

		/**
		 *   Get the item type.
		 */
		virtual SType GetItemType() const
		{
			return typeDescriptor->GetItemType();
		}

		/**
		 *   Returns true is the vector is a vector of byte.
		 */
		virtual bool IsBuffer()
		{
			return GetItemType() == STypeByte;
		}

		/**
		 * Return the length of the vector.
		 */
		virtual int GetLength()
		{
			return values->size();
		}

		/**
		 *   Get the type descriptor.
		 */
		virtual TypeDescriptorSp GetTypeDescriptor()
		{
			return typeDescriptor;
		}

		/**
		 *   Add an item in the vector.
		 */
		virtual void AddItem(SValueSp value);

		/**
		 * Get an item.
		 */
		virtual SValueSp Get(int index);

		/**
		 * Get an item and try to cast it.
		 */
		template <typename T>
		shared_ptr<T> Get(int index)
		{
			return Get(index)->As<T>();
		}

		/**
		 * Returns a string representation of the value.
		 */
		virtual string ToString() 
		{ 
			return SComplexValue::ToString(); 
		}

		/**
		* Returns a string representation of the value in a specific format.
		*/
		virtual string ToString(string format);

		/**
		*   Factory method to create a SVector variable instance.
		*/
		static SVectorSp Create(SVectorTypeDescriptorSp typeDescriptor);

		/**
		 *   Factory method to create a SVector variable from a string.
		 */
		static SVectorSp Parse(SVectorTypeDescriptorSp typeDescriptor, string s);
		static SVectorSp Parse(SVectorTypeDescriptorSp typeDescriptor, string s, SValueSpMapSp vars);

};

#endif  //_SVECTOR_H